![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@travetto/registry
Advanced tools
Patterns and utilities for handling registration of metadata and functionality for run-time use
Install: @travetto/registry
npm install @travetto/registry
# or
yarn add @travetto/registry
This module is the backbone for all "discovered" and "registered" behaviors within the framework. This is primarily used for building modules within the framework and not directly useful for application development.
Registration, within the framework flows throw two main use cases:
The primary flow occurs on initialization of the application. At that point, the module will:
Code: Sample Registry
import { Class } from '@travetto/base';
import { MetadataRegistry } from '@travetto/registry';
interface Group {
class: Class;
name: string;
}
interface Child {
name: string;
method: Function;
}
function isComplete(o: Partial<Group>): o is Group {
return !!o;
}
export class SampleRegistry extends MetadataRegistry<Group, Child> {
/**
* Finalize class after all metadata is collected
*/
onInstallFinalize<T>(cls: Class<T>): Group {
const pending: Partial<Group> = this.getOrCreatePending(cls);
if (isComplete(pending)) {
return pending;
} else {
throw new Error('Invalid Group');
}
}
/**
* Create scaffolding on first encounter of a class
*/
createPending(cls: Class): Partial<Group> {
return {
class: cls,
name: cls.name
};
}
}
The registry is a MetadataRegistry that similar to the Schema's Schema registry and Dependency Injection's Dependency registry.
At runtime, the registry is designed to listen for changes and to propagate the changes as necessary. In many cases the same file is handled by multiple registries.
As the DynamicFileLoader notifies that a file has been changed, the RootRegistry will pick it up, and process it accordingly.
As mentioned in Manifest's readme, the framework produces hashes of methods, classes, and functions, to allow for detecting changes to individual parts of the codebase. During the live flow, various registries will inspect this information to determine if action should be taken.
Code: Sample Class Diffing
#handleFileChanges(file: string, classes: Class[] = []): void {
const next = new Map<string, Class>(classes.map(cls => [cls.Ⲑid, cls] as const));
let prev = new Map<string, Class>();
if (this.#classes.has(file)) {
prev = new Map(this.#classes.get(file)!.entries());
}
const keys = new Set([...Array.from(prev.keys()), ...Array.from(next.keys())]);
if (!this.#classes.has(file)) {
this.#classes.set(file, new Map());
}
let changes = 0;
/**
* Determine delta based on the various classes (if being added, removed or updated)
*/
for (const k of keys) {
if (!next.has(k)) {
changes += 1;
this.emit({ type: 'removing', prev: prev.get(k)! });
this.#classes.get(file)!.delete(k);
} else {
this.#classes.get(file)!.set(k, next.get(k)!);
if (!prev.has(k)) {
changes += 1;
this.emit({ type: 'added', curr: next.get(k)! });
} else {
const prevMeta = RootIndex.getFunctionMetadataFromClass(prev.get(k));
const nextMeta = RootIndex.getFunctionMetadataFromClass(next.get(k));
if (prevMeta?.hash !== nextMeta?.hash) {
changes += 1;
this.emit({ type: 'changed', curr: next.get(k)!, prev: prev.get(k) });
}
}
}
}
if (!changes) {
this.#emitter.emit('unchanged-file', file);
}
}
FAQs
Patterns and utilities for handling registration of metadata and functionality for run-time use
The npm package @travetto/registry receives a total of 47 weekly downloads. As such, @travetto/registry popularity was classified as not popular.
We found that @travetto/registry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.